package com.east.sng.service.impl;

import com.east.sng.dao.StuDao;
import com.east.sng.entity.param.StuParam;
import com.east.sng.entity.param.StuSearchParam;
import com.east.sng.entity.result.StuCourseFind;
import com.east.sng.entity.result.StuFind;
import com.east.sng.entity.result.StuInfo;
import com.east.sng.entity.result.StuSearchFind;
import com.east.sng.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author east
 * @date: 2021/12/31
 * @Description:
 **/
@Service
public class StuServiceImpl implements StuService {
    @Autowired
    private StuDao stuDao;

    @Override
    public List<StuInfo> findStus(StuSearchParam params) {
        return this.stuDao.selectStus(params);
    }

    @Override
    public List<StuSearchFind> findStuColumns(String stuName) {
        return stuDao.selectStuColumns(stuName);
    }

    @Override
    public StuFind findStu(Integer stuId) {
        return this.stuDao.selectStu(stuId);
    }

    @Override
    public void addStu(StuParam stu) {
        this.stuDao.insertStu(stu);
    }

    @Override
    public void editStu(StuParam stu) {
        this.stuDao.updateStu(stu);
    }

    @Override
    public boolean removeStu(Integer stuId) {
        return this.stuDao.deleteOrRecoverStu(stuId,1) > 0;
    }

    @Override
    public boolean recoverStu(Integer stuId) {
        return this.stuDao.deleteOrRecoverStu(stuId,0) > 0;
    }

    @Override
    public boolean batchRemoveStus(List<Integer> stuIds) {
        return this.stuDao.batchDeleteOrRecoverStus(stuIds,1) > 0;
    }

    @Override
    public boolean batchRecoverStus(List<Integer> stuIds) {
        return this.stuDao.batchDeleteOrRecoverStus(stuIds,0) > 0;
    }

    @Override
    public StuCourseFind findStuCourseInfo(Integer stuId) {
        return stuDao.selectStuCourseInfo(stuId);
    }

    @Override
    public List<StuInfo> findStuInfo(List<Integer> stuIds) {
        return stuDao.selectStuInfo(stuIds);
    }
}